﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace Sandbox.Editor.Modes.ModePanels
{
	/// <summary>
	/// Interaction logic for RefImagePanel.xaml
	/// </summary>
	public partial class RefImagePanel : UserControl
	{
		public RefImagePanel()
		{
			InitializeComponent();
		}

		public RefImageMode Mode
		{
			get;
			set;
		}

		private void ButtonAddImage_Click(object sender, RoutedEventArgs e)
		{
			// Create OpenFileDialog
			System.Windows.Forms.OpenFileDialog dlg = new System.Windows.Forms.OpenFileDialog();

			// Set filter for file extension and default file extension
			dlg.DefaultExt = ".png";
			dlg.Filter = "Images (.png)|*.png";

			if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
			{
				Mode.OnAddingImage(dlg.FileName);
			}
		}

		private void SliderOpacity_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
		{
			Mode.OnOpacitySliderChanged(e);
		}

		private void ListBoxImage_SelectionChanged(object sender, SelectionChangedEventArgs e)
		{
			Mode.OnImageSelectionChanged(e);
		}
	}
}
